home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 June / EnigmA AMIGA RUN 19 (1997)(G.R. Edizioni)(IT)[!][issue 1997-06][EAR-CD III].iso / softwareupdate / system / atapi_pnp300 / developer_kit / playmsf.c < prev    next >
C/C++ Source or Header  |  1996-02-04  |  3KB  |  98 lines

  1. /****************************************************************************
  2. *
  3. *
  4. *   $VER: PlayMSF.c  1.0 (22 Jan 1996) by M_Campinoti CD++
  5. *
  6. *   $HISTORY:
  7. *
  8. *   22 Jan 1996 : 001.000 : First and Last release of an example that show
  9. *                           how to play audio tracks by means of
  10. *                           CD_PLAYMSF command.
  11. *                           Didactical use, so CLI only      :)
  12. *
  13. ****************************************************************************/
  14.  
  15. #include <proto/exec.h>
  16. #include <exec/devices.h>
  17. #include <exec/io.h>
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21.  
  22. #include "atapi_cd.h"
  23.  
  24.  
  25. /*                 minutes,seconds,frames to play (default 1m,1sec,1fr) */
  26.  
  27. main (UBYTE argc,UBYTE** argv)
  28. {
  29.     struct IOStdReq      *ioreq ;
  30.     struct MsgPort       *reply ;
  31.     ULONG                m_start,f_start,s_start;
  32.     ULONG                m_len,f_len,s_len;
  33.     ULONG                start , length ;
  34.  
  35.     f_len = 0 ;
  36.     s_len = 0 ;
  37.  
  38.  
  39.     switch(argc)
  40.     {
  41.      case 0:
  42.          return;         /* it came from workbench .... */
  43.          break;
  44.      default:
  45.      case 1:
  46.      case 2:
  47.      case 3:
  48.      case 4:
  49.          printf("USAGE: PlayMSF startM startS startF  lenM lenS lenF\n \
  50. Example: PlayMSF 0 2 0   1 2 3");
  51.          return;        /* Yes, this isn't a cool template, but is quickly ! (i'm lazy) */
  52.      case 7:
  53.          f_len = atoi(argv[6]);
  54.      case 6:
  55.          s_len = atoi(argv[5]);
  56.      case 5:
  57.          m_len = atoi(argv[4]);
  58.          f_start = atoi(argv[3]);
  59.          s_start = atoi(argv[2]);
  60.          m_start = atoi(argv[1]);
  61.          break;
  62.     }
  63.  
  64.     start  = (m_start<<16) | (s_start<<8) | f_start ;
  65.     length = (m_len  <<16) | (s_len  <<8) | f_len   ;
  66.  
  67.  
  68.  
  69.     if( reply = CreateMsgPort() )
  70.     {
  71.       if( ioreq = (struct IOStdReq *)
  72.              CreateIORequest(reply ,sizeof(struct  IOStdReq)) )
  73.       {
  74.         if(!OpenDevice("cd.device",0,(struct IORequest*)ioreq,NULL) )
  75.         {
  76.           ioreq->io_Command = CD_PLAYMSF;
  77.           ioreq->io_Offset  = start;
  78.           ioreq->io_Length  = length;
  79.  
  80.           printf("Start Playing at requested MSF ...\n");
  81.  
  82.           DoIO((struct IORequest*)ioreq);
  83.           
  84.           if (ioreq->io_Error)
  85.                printf("I/O error !\n");     /* analyze ioreq->io_Error to know what kind ... */
  86.                                             /* ... see atapi_cd.h for #defines of it !       */
  87.           
  88.           CloseDevice((struct IORequest *)ioreq) ;
  89.         }
  90.         
  91.         DeleteIORequest(ioreq) ;
  92.       }
  93.  
  94.       DeleteMsgPort(reply);
  95.     }
  96. }
  97.  
  98.